package com.edu.admin.common;

import org.apache.http.HttpStatus;

/**
 * 返回数据
 * 
 * @author Wangjiong
 */
public class RestResult {
	
	private int code;
	private String msg;
	private Object data;

	public RestResult() {
		this.code = HttpStatus.SC_OK;
		this.msg = "success";
	}

	public static RestResult error() {
		return error(0, "操作失败");
	}

	public static RestResult error(String msg) {
		return error(0, msg);
	}

	public static RestResult error(int code, String msg) {
		RestResult r = new RestResult();
		r.setCode(code);
		r.setMsg(msg);
		return r;
	}

	public static RestResult ok(Object object) {
		RestResult r = new RestResult();
		r.setData(object);
		return r;
	}

	public static RestResult ok() {
		return new RestResult();
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	

}
